reverse a linked list hackerrank python